package com.suitsoft.ut.entity.base;

import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.google.common.collect.Lists;
import com.suitsoft.ut.entity.IdEntity;
import com.suitsoft.ut.entity.account.User;
import com.suitsoft.ut.entity.commons.Examination;


/**
 * 教师信息
 *@author Suineg
 */
@Entity
@Table(name = "BD_TEACHER")
public class Teacher extends IdEntity{
	/** 教师名 */
	private String teacherName;
	/** 教师编号  */
	private String teacherNo;
	/** 工作时间 */
	private Date teacherWorkDate;
	/** 教师电话 */
	private String teacherTelephone;
	/** EMAIL */
	private String teacherEmail;
	/** 最后操作人 */
	
	private User lastUser;
	/** 备注*/
	private String teacherMemo;
	/** 学院  */
	private College college;
	/** 学院 名 */
	private String teacherCollege;
	/** 账户信息 (即此人对应的账户信息) */
	private User forUser;
	/** 团队 */
	private List<Team> teamList = Lists.newArrayList();
	
	/** 是否是负责人 */
	private Integer isMaster;
	/** 职称 */
	private String titile;
	/** 最后操作时间 */
	private Date lastDate;
	/** 自查表 */
	private Examination examination;
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "EXAMINATION")
	public Examination getExamination() {
		return examination;
	}
	public void setExamination(Examination examination) {
		this.examination = examination;
	}
	//多对多定义
	@ManyToMany
	//中间表定义,表名采用默认命名规则
	@JoinTable(name = "LW_TEACHER_GROUP", joinColumns = { @JoinColumn(name = "TEACHER_ID") }, inverseJoinColumns = { @JoinColumn(name = "GROUP_ID") })
	//Fecth策略定义
	@Fetch(FetchMode.SUBSELECT)
	//集合按id排序.
	@OrderBy("id")
	//集合中对象id的缓存.
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<Team> getTeamList() {
		return teamList;
	}
	public void setTeamList(List<Team> teamList) {
		this.teamList = teamList;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "FOR_USER_ID")
	public User getForUser() {
		return forUser;
	}
	public void setForUser(User forUser) {
		this.forUser = forUser;
	}
	public String getTeacherName() {
		return teacherName;
	}
	public void setTeacherName(String teacherName) {
		this.teacherName = teacherName;
	}
	public String getTeacherNo() {
		return teacherNo;
	}
	public void setTeacherNo(String teacherNo) {
		this.teacherNo = teacherNo;
	}
	public Date getTeacherWorkDate() {
		return teacherWorkDate;
	}
	public void setTeacherWorkDate(Date teacherWorkDate) {
		this.teacherWorkDate = teacherWorkDate;
	}
	public String getTeacherTelephone() {
		return teacherTelephone;
	}
	public void setTeacherTelephone(String teacherTelephone) {
		this.teacherTelephone = teacherTelephone;
	}
	public String getTeacherEmail() {
		return teacherEmail;
	}
	public void setTeacherEmail(String teacherEmail) {
		this.teacherEmail = teacherEmail;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "USER_ID")
	public User getLastUser() {
		return lastUser;
	}
	public void setLastUser(User lastUser) {
		this.lastUser = lastUser;
	}
	public String getTeacherMemo() {
		return teacherMemo;
	}
	public void setTeacherMemo(String teacherMemo) {
		this.teacherMemo = teacherMemo;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "COLLEGE_ID")
	public College getCollege() {
		return college;
	}
	public void setCollege(College college) {
		this.college = college;
	}
	public Integer getIsMaster() {
		return isMaster;
	}
	public void setIsMaster(Integer isMaster) {
		this.isMaster = isMaster;
	}
	public String getTitile() {
		return titile;
	}
	public void setTitile(String titile) {
		this.titile = titile;
	}
	public Date getLastDate() {
		return lastDate;
	}
	public void setLastDate(Date lastDate) {
		this.lastDate = lastDate;
	}
	
	public void copy(TeacherTemp teacherTemp){
		this.teacherEmail = teacherTemp.getEmail();
		this.teacherMemo = teacherTemp.getMemo();
		this.teacherName = teacherTemp.getName();
		this.teacherNo = teacherTemp.getNo();
		this.teacherTelephone = teacherTemp.getTelephone();
		this.teacherWorkDate = teacherTemp.getWorkDate();
		this.titile = teacherTemp.getTitile();
	}
	public String getTeacherCollege() {
		return teacherCollege;
	}
	public void setTeacherCollege(String teacherCollege) {
		this.teacherCollege = teacherCollege;
	}
}

